<template>
<view>
	<uni-search-bar
		v-model="searchForm.sfindInfo"
		placeholder="请输入查询条件"
		@confirm="search"
		@cancel="cancel"
	></uni-search-bar>
	
	<view class="table">
		<uni-card 
			v-for="item in captionList"
			:key="item.id"
			class="m-b-10"
			margin="0"
			:title="'订单号:' + item.sorderNo"
			:sub-title="'款号:' + item.sstyleNo"
			:extra="item.sworkTeamName"
			:thumbnail="item.surl"
			@click="onClick(item)">
			<text class="uni-body">
				<view class="caption-box">
					<view class="caption-item">
						<view class="name">单据号:</view>
						<view class="">{{ item.sbillNo }} </view>
					</view>
					<view class="caption-item">
						<view class="name">颜色:</view>
						<view class=""> {{ item.scolorName }} </view>
					</view>
					<view class="caption-item">
						<view class="name">订单类型:</view>
						<view class=""> {{ item.sorderType }} </view>
					</view>
					<view class="caption-item">
						<view class="name">包号:</view>
						<view class=""> {{ item.slotNo }} </view>
					</view>
				</view>
			</text>
			<view slot="actions" class="card-actions">
				<view class="card-actions-item">
					<text class="card-actions-item-text">数量:{{ item.iqty }}</text>
				</view>
				<view class="card-actions-item">
					<text class="card-actions-item-text">包数:{{ item.icutqty }}</text>
				</view>
				<view class="card-actions-item">
					<text class="card-actions-item-text">时间:{{ item.createTime }}</text>
				</view>
			</view>
		</uni-card>
	</view>
</view>
</template>

<script>
	import { sum } from "lodash";
	import fabricService from "@/api/auth/fabricService";
	export default {
		data() {
			return {
				searchForm: {
					sfindInfo: "",
					current: -1,
					size: -1
				},
				captionList: [],
			}
		},
		// 加载
		onLoad(option) {
			uni.showLoading({
				title: '加载中'
			});
			fabricService.getCutPakeage(this.searchForm).then(res => {
				this.captionList = res.records;
				uni.hideLoading();
			}).catch(error => {
				uni.hideLoading();
			})
		},
		methods: {
			search() {
				this.captionList = [];
				uni.showLoading();
				fabricService.getCutPakeage(this.searchForm).then(res => {
					uni.hideLoading();
					if (res.records.length === 0) {
						uni.showToast({
							title: "无数据",
							icon: "error"
						})
						return false
					}
					this.captionList = res.records;
				})
			},
			cancel() {
				this.searchForm.sFindValue = "";
			},
			maskClick(e){
				this.searchForm.dFindBegin = e[0];
				this.searchForm.dFindEnd = e[1];
			},
			onClick(row) {
				uni.navigateTo({
					url: `/pages/subB/reportWork/cutDetail?id=${row.id}`
				});
			}
		}
	}
</script>

<style scoped lang="scss">
.table {
	width: 710rpx;
	margin: 0 auto;
	border-radius: 20rpx;
	font-size: 12px;
	.caption-box {
		display: flex;
		flex-wrap: wrap;
		.caption-item {
			width: 50%;
			display: flex;
			align-items: center;
			margin-bottom: 20rpx;
		}
	}
	.m-b-10 {
		margin-bottom: 10px!important;
	}
}

.card-actions {
		display: flex;
		flex-direction: row;
		justify-content: space-around;
		align-items: center;
		height: 40px;
		border-top: 1px #eee solid;
	}
	.card-actions-item {
		display: flex;
		flex-direction: row;
		align-items: center;
	}
	.card-actions-item-text {
		font-size: 12px;
		color: #666;
		margin-left: 5px;
	}
	.cover-image {
		flex: 1;
		height: 150px;
	}
	.no-border {
		border-width: 0;
	}
</style>